
<%@page import="org.json.simple.JSONValue"%>
<%@page import="java.io.IOException"%>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="java.sql.*" %>
<html>
    <body>
<%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stock","root","");  
    
   // String sql = "select company.com_nm,time,price from day_long,company where company.com_id=day_long.com_id and company.com_id='1'";
        String sql="select high,com_id,low from com_history";
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery(sql);

    JSONObject jSONObject = new JSONObject();
    JSONArray array = new JSONArray();
    JSONArray array1 = new JSONArray();
        
    while(rs.next())
    {
        jSONObject.put("name", rs.getString(2));
        array.add(Double.parseDouble(rs.getString(1)));
        array1.add(Double.parseDouble(rs.getString(3)));
        
    }   
       jSONObject.put("time",array);
       jSONObject.put("price",array1);
       
       out.print(array.toJSONString());
       out.print(array.toString());
       
       array.toString();

%>